// 录制状态
const recording = val => {
  let statusText = ""
  switch (val) {
    case 0:
      statusText = "未开始"
      break;
    case 1:
      statusText = "准备录制"
      break;
    case 2:
      statusText = "准备录制"
      break;
    case 3:
      statusText = "录制中"
      break;
    case 4:
      statusText = "录制完成"
      break;
    default:
      statusText = ""
  }
  return statusText
}
//视频类型
const titleState = val => {
  var text = "";
  if (!val) {
    text = "";
  }
  switch (val) {
    case 0:
      text = "会议视频"
      break;
    case 1:
      text = "监控视频"
      break;
    case 3:
      text = "电话视频"
      break;
    case 4:
      text = "电视邮件"
      break;
    case 5:
      text = "报警视频";
      break;
    case 6:
      text = "吹哨报道";
      break;
  }
  return text;
}
// 审核状态
const auditState = val => {
  var text = ""
  switch (val) {
    case 0:
      text = "已审核"
      break;
    case 1:
      text = "未审核"
      break;
  }
  return text
}
// 视频标题截取
const capturename = value => {
  if (value) {
    return value.length > 20 ? value.substring(0, 20) + '...' : value;
  }
  return "";
}

//把秒转换成 00:00:00时间格式 筛选器
const stime = value => {
  var _txt = '';
  if (!value) {
    return "00:00:00";
  }

  function addZero(_v) {
    return _v > 9 ? _v : '0' + _v;
  }
  var _h = addZero(parseInt(value / 3600)),
    _m = addZero(parseInt(value % 3600 / 60)),
    _s = addZero(value % 60);

  _txt = _h + ':' + _m + ':' + _s;

  return _txt;
}
// 时间戳转换成年月日时分秒 
const timeYmdHms = value => {
  if (!value) {
    return '';
  }

  var date = new Date(value),
    Y = date.getFullYear(),
    m = date.getMonth() + 1,
    d = date.getDate(),
    H = date.getHours(),
    i = date.getMinutes(),
    s = date.getSeconds();
  if (m < 10) {
    m = '0' + m;
  }
  if (d < 10) {
    d = '0' + d;
  }
  if (H < 10) {
    H = '0' + H;
  }
  if (i < 10) {
    i = '0' + i;
  }
  if (s < 10) {
    s = '0' + s;
  }
  let t = Y + '-' + m + '-' + d + ' ' + H + ':' + i + ':' + s;

  return t;
}

// 手机号脱敏('13912345678' 转换成 '139****5678') 第3位开始替换4个
const telHide = num => {
  let data = num.replace(/(\d{3})\d{4}(\d*)/, '$1****$2')
  return data
}


export default {
  recording, //录制状态
  titleState, //视频类型
  capturename, //视频标题
  stime, //视频时间转换秒数
  timeYmdHms, //时间戳转换成年月日时分秒
  auditState,//审核状态
  telHide,
}